Xbasic

Array lower Method

Syntax

V <array>.lower()

Returns

resultNumeric

The lower bound of the array - this is the index of the first element in the array.

Description

Returns the lower bound of the array.

Discussion

Arrays can be defined with custom indexes. For example:

dim rarr[2..5] as c

The Xbasic array rarr is defined with a lower bound of 2 and upper bound of 5. This means the index of the first element in the array is 2. The <array>.lower() method can be used to get the lower bound for an array. This is useful if you know the array was created with a lower bound that is not 1.

? rarr.lower()
= 2

Changing the lower bound is often use to create zero-indexed arrays. For example:

dim zarr[0..9] as na
for i = 0 to 9
    zarr[i] = i
next

? zarr[0]
= 0

? zarr[9]
= 9

? zarr.size()
= 10

? zarr[10]
ERROR: Array index out-of-bounds

See Also